package com.tencreat.mall.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tencreat.common.annotation.Log;
import com.tencreat.common.core.HttpResult;
import com.tencreat.common.core.controller.BaseController;
import com.tencreat.common.core.domain.AjaxResult;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.enums.BusinessType;
import com.tencreat.common.utils.poi.ExcelUtil;
import com.tencreat.domain.mall.MallGoodsKill;
import com.tencreat.domain.mall.vo.ResGoodsKillDetailVO;
import com.tencreat.domain.mall.vo.ResGoodsKillListAppVO;
import com.tencreat.domain.mall.dto.GoodsKillListAppDTO;
import com.tencreat.mapper.mall.MallGoodsKillMapper;
import com.tencreat.service.mall.IMallGoodsKillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 商品秒杀Controller
 *
 * @author wangkai
 * @date 2021-11-16
 */
@Api(tags={"6-秒杀商品"})
//@RestController
@RequestMapping("/api/kill")
public class MallGoodsKillController extends BaseController {
    //@Autowired
    private IMallGoodsKillService mallGoodsKillService;

    //@Autowired
    MallGoodsKillMapper mallGoodsKillMapper;

    /**
     * 查询商品秒杀列表
     */
    @ApiOperation(value = "查询商品秒杀列表")
    @PostMapping("/list")
    @Deprecated
    public HttpResult<IPage<ResGoodsKillListAppVO>> list(@RequestBody GoodsKillListAppDTO vo) {
        Page<ResGoodsKillListAppVO> page = new Page<>(vo.getPageNum(), vo.getPageSize());
        return HttpResult.ok(mallGoodsKillService.page(page, vo));
    }

    /**
     * 获取商品秒杀详细信息
     */
    @ApiOperation(value = "获取商品秒杀详细信息")
    @PostMapping(value = "/getInfo")
    public HttpResult<ResGoodsKillDetailVO> getInfo(@RequestBody ReqIdParam id) {
        return mallGoodsKillService.selectMallGoodsKillById(id, getLoginCheck());
    }

    /**
     * 查询秒杀专区列表
     */
    @GetMapping("/killZoneList")
    @ApiOperation("查询秒杀专区列表")
    public HttpResult<?> killZoneList(){
        return HttpResult.ok(mallGoodsKillMapper.killZoneList());
    }

}
